<%--
  Created by IntelliJ IDEA.
  User: jia19
  Date: 2015/10/8
  Time: 8:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <title>后台管理系统——图书管理</title>
    <%@ include file="../../layout/import.jsp"%>

    <script type="text/javascript">
        function submit() {
            $.ajax({
                url: "/admin/addBook.do",
                data: $('#bookForm').serialize(),
                method: "POST",
                dataType: "json",
                error: function () {
                    alert("表单提交出错，请稍后再试");
                },
                success: function(response) {
                    if(response.code == 0) {
                        alert("添加成功");
                        window.location.href = "/admin/book.do";

                    }
                    else {
                        alert(response.description);
                    }
                }
            });
        }
    </script>

</head>
<body>
<%@ include file="nav.jsp"%>

<div class="container" style="min-height: 72%">
    <div class="col-sm-8 col-sm-offset-2">

        <form class="form" id="bookForm">
            <div class="form-group">
                <label for="isbn">书号</label>
                <input type="text" class="form-control" id="isbn" name="isbn">
            </div>
            <div class="form-group">
                <label for="bookName">书名</label>
                <input type="text" class="form-control" id="bookName" name="bookName">
            </div>
            <div class="form-group">
                <label for="author">作者</label>
                <input type="text" class="form-control" id="author" name="author">
            </div>
            <div class="form-group">
                <label for="publisher">出版社</label>
                <select class="form-control" id="publisher" name="publisher">
                    <c:forEach var="publisher" items="${publisherList}">
                        <option value="${publisher.id}">${publisher.name}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="form-group">
                <label for="publishDate">出版日期</label>
                <input type="date" class="form-control" id="publishDate" name="publishDate">
            </div>
            <div class="form-group">
                <label for="price">价格</label>
                <input type="text" class="form-control" id="price" name="price">
            </div>
            <div class="form-group">
                <label for="quantity">库存数量</label>
                <input type="number" class="form-control" id="quantity" name="quantity">
            </div>
            <div class="form-group">
                <label for="place">存储位置</label>
                <input type="text" class="form-control" id="place" name="place">
            </div>
            <div class="form-group">
                <label for="category">分类</label>
                <input type="text" class="form-control" id="category" name="category">
            </div>
            <div class="form-group">
                <label for="type">类型</label>
                <select class="form-control" id="type" name="type">
                    <option value="0">普通</option>
                    <option value="1">精品</option>
                    <option value="2">新书</option>
                    <option value="3">首页</option>
                </select>
            </div>
            <div class="form-group">
                <label for="content">内容简介</label>
                <textarea class="form-control" id="content" name="content" rows="3"></textarea>
            </div>

            <a class="btn btn-primary" onclick="submit()">提交</a>

        </form>

    </div>
</div>


<%@ include file="../footer.jsp"%>
</body>
</html>
